
package a66weding.com.jiehuntong.activity;

import android.Manifest;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.makeramen.roundedimageview.RoundedImageView;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.activity.home.BaseHomeActivity;
import a66weding.com.jiehuntong.application.DataWareHourse;
import a66weding.com.jiehuntong.beans.ErrorBean;
import a66weding.com.jiehuntong.beans.HttpRequestBean;
import a66weding.com.jiehuntong.beans.MarryInviteBean;
import a66weding.com.jiehuntong.beans.SimpleBean;
import a66weding.com.jiehuntong.beans.SuccessBean;
import a66weding.com.jiehuntong.common.api.Url;
import a66weding.com.jiehuntong.common.utils.CUtils;
import a66weding.com.jiehuntong.common.utils.FileUtil;
import a66weding.com.jiehuntong.common.utils.LogUtil;
import a66weding.com.jiehuntong.common.utils.Tools;
import a66weding.com.jiehuntong.common.utils.Utils;
import a66weding.com.jiehuntong.http.HttpHandleUtil;
import a66weding.com.jiehuntong.http.OnNetResultListener;
import a66weding.com.jiehuntong.http.RequestCode;
import a66weding.com.jiehuntong.view.WheelView;

import static a66weding.com.jiehuntong.R.color.lightgrey2;
import static a66weding.com.jiehuntong.R.color.skyblue;
import static a66weding.com.jiehuntong.R.id.tel_et;
/**
 * 新人信息界面
 */
public class InformationActivity extends BaseHomeActivity implements View.OnClickListener, OnNetResultListener, WheelView.OnSelectListener {
    private LinearLayout ll_top_decorate;// 会员头像背景
    private RoundedImageView img_top_head;// 会员头像
    private EditText my_name;// 会员名字
    private EditText my_tel;// 会员电话
    private TextView tv_my_role;// 我的角色
    private LinearLayout ll_bottom_decorate;// 会员对象头像背景
    private RoundedImageView img_bootom_head;// 会员对象头像
    private EditText other_name_et;// 会员对象名字
    private TextView tv_wedding_day;// 婚期
    private TextView tv_address;// 婚礼举办地
    private EditText domain_name_et;// 婚礼域名
    private EditText other_tel_et;// 绑定手机号（另一半电话）
    private TextView domain_tv;// .lovewith.me
    private Dialog dialog;// 图片与角色弹框
    private boolean isTopHead = true;// 是否是会员头像
    private String headPath;// 会员头像地址
    private String headPathOther;// 会员对象头像地址
    private String role;// 会员角色
    private String myHaed;// 会员头像地址裁剪后的也就是要上传的
    private String otherHaed;// 会员对象头像地址裁剪后的裁剪后的也就是要上传的
    private PopupWindow mDatePopupWindow;
    private WheelView mViewYear;
    private WheelView mViewMonth;
    private WheelView mViewDay;
    private String currentYear = "2016";//默认年份(也是当前的)
    private String currentMonth = "01";//默认月份(也是当前的两位的)
    private String currentDay = "01";//默认1号(也是当前的两位的)
    private String currentHour = "00";//默认时间(也是当前的两位的)
    private String currentMinute = "00";//默认分钟(也是当前的两位的)
    private static final int PERMISSION_SDCARD = 4;// 拍照权限
    private static final int PERMISSION_CAMERA = 5;// 图库权限
    private final int ADDRESS = 6;// 地图选取地址
    private Context context;
    private MarryInviteBean.DataBean marryInvite;
    private double mLongitude;
    private double mLatitude;
    private String url;
    private Drawable drawable;
    private Drawable drawableOther;
    private WheelView mViewHour;
    private WheelView mViewMinute;
    private ArrayList<String> mYears;
    private ArrayList<String> mMonths;
    private ArrayList<String> mHours;
    private ArrayList<String> mMinutes;
    private int uId;
    private  boolean isGetInformation=false;
    // 1:新郎头像 2:新娘头像
    boolean isTopBride;//根据这个判断新郎新娘角色然后更新颜色(点击新郎新娘切换角色的时候用到的)上传头像区分男女
    private TextView myname_tv;
    private TextView role_tv;
    private TextView tel_tv;
    private TextView other_name_tv;
    private TextView tv_we_weddingDate;
    private TextView address_tv;
    private TextView other_tel_tv;
    private TextView domain_name_tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_information);
        context = this;
        isGetInformation=false;
        initViews();
        initInfo();
        loadData();
    }

    public void setTopColor() {
        if (isTopBride) {
            Drawable drawable = getResources().getDrawable(R.mipmap.bedeckw);//装饰
            ll_top_decorate.setBackgroundDrawable(drawable);//设置装饰
            img_top_head.setBorderColor(getResources().getColor(R.color.colorMainRed));//我的头像
            my_name.setTextColor(getResources().getColor(R.color.colorMainRed));//编辑我的名字
            tv_my_role.setTextColor(getResources().getColor(R.color.colorMainRed));//编辑我的角色
            my_tel.setTextColor(getResources().getColor(R.color.colorMainRed));//编辑我的电话
            myname_tv .setTextColor(getResources().getColor(R.color.clay));//我的名字提示
            role_tv .setTextColor(getResources().getColor(R.color.clay));//我的角色提示
            tel_tv.setTextColor(getResources().getColor(R.color.clay));//我的电话提示
        } else {
            Drawable drawable = getResources().getDrawable(R.mipmap.bedeckm);//装饰
            ll_top_decorate.setBackgroundDrawable(drawable);//设置装饰
            img_top_head.setBorderColor(getResources().getColor(R.color.skyblue));//我的头像
            my_name.setTextColor(getResources().getColor(skyblue));//编辑我的名字
            tv_my_role.setTextColor(getResources().getColor(R.color.skyblue));//编辑我的角色
            my_tel.setTextColor(getResources().getColor(R.color.skyblue));//编辑我的电话
            myname_tv .setTextColor(getResources().getColor(lightgrey2));//我的名字提示
            role_tv .setTextColor(getResources().getColor(lightgrey2));//我的角色提示
            tel_tv.setTextColor(getResources().getColor(lightgrey2));//我的电话提示
        }
    }
    public void setBottomColor() {
        if (isTopBride) {//如果上半部分是新娘,这里就是男的
            //另一半
            Drawable drawable = getResources().getDrawable(R.mipmap.bedeckm);//装饰
            ll_bottom_decorate.setBackgroundDrawable(drawable);//设置装饰
            other_name_tv .setTextColor(getResources().getColor(R.color.lightgrey2));   //另一半名字提示
            tv_we_weddingDate .setTextColor(getResources().getColor(R.color.lightgrey2));//我们的婚期提示
            address_tv .setTextColor(getResources().getColor(R.color.lightgrey2)); //婚礼举办地提示
            domain_name_tv .setTextColor(getResources().getColor(R.color.lightgrey2)); //婚礼域名提示.
            other_tel_tv.setTextColor(getResources().getColor(R.color.lightgrey2));//提示另一半电话
            //编辑
            img_bootom_head.setBorderColor(getResources().getColor(R.color.skyblue));//另一半头像
            other_name_et.setTextColor(getResources().getColor(R.color.skyblue));//编辑另一半名字
            tv_wedding_day.setTextColor(getResources().getColor(R.color.skyblue));//婚礼日期
            tv_address.setTextColor(getResources().getColor(R.color.skyblue));//举办地
            domain_name_et.setTextColor(getResources().getColor(R.color.skyblue));//编辑婚礼域名前缀
            domain_tv.setTextColor(getResources().getColor(R.color.skyblue));//婚礼后缀
            other_tel_et.setTextColor(getResources().getColor(R.color.skyblue));//编辑另一半电话
        } else {
            Drawable drawable = getResources().getDrawable(R.mipmap.bedeckw);//装饰
            ll_bottom_decorate.setBackgroundDrawable(drawable);//设置装饰
            other_name_tv .setTextColor(getResources().getColor(R.color.clay));   //另一半名字提示
            tv_we_weddingDate .setTextColor(getResources().getColor(R.color.clay));//我们的婚期提示
            address_tv .setTextColor(getResources().getColor(R.color.clay)); //婚礼举办地提示
            domain_name_tv .setTextColor(getResources().getColor(R.color.clay)); //婚礼域名提示.
            other_tel_tv.setTextColor(getResources().getColor(R.color.clay));//提示另一半电话
            //编辑
            img_bootom_head.setBorderColor(getResources().getColor(R.color.colorMainRed));//另一半头像
            other_name_et.setTextColor(getResources().getColor(R.color.colorMainRed));//编辑另一半名字
            tv_wedding_day.setTextColor(getResources().getColor(R.color.colorMainRed));//婚礼日期
            tv_address.setTextColor(getResources().getColor(R.color.colorMainRed));//举办地
            domain_name_et.setTextColor(getResources().getColor(R.color.colorMainRed));//编辑婚礼域名前缀
            domain_tv.setTextColor(getResources().getColor(R.color.colorMainRed));//婚礼后缀
            other_tel_et.setTextColor(getResources().getColor(R.color.colorMainRed));//编辑另一半电话
        }
    }
    /**
     * 初始化控件
     */
    private void initViews() {
        //我的
        ll_top_decorate = (LinearLayout) findViewById(R.id.ll_top_decorate);//我的头像装饰
        img_top_head = (RoundedImageView) findViewById(R.id.img_top_head);//我的头像
        img_top_head.setImageDrawable(getResources().getDrawable(R.mipmap.headm));
        myname_tv = (TextView) findViewById(R.id.myname_tv);//我的名字提示
        my_name = (EditText) findViewById(R.id.my_name);//编辑我的名字
        role_tv = (TextView) findViewById(R.id.role_tv);//我的角色提示
        tv_my_role = (TextView) findViewById(R.id.tv_my_role);//编辑我的角色
        tel_tv = (TextView) findViewById(R.id.tel_tv);//我的电话提示
        my_tel = (EditText) findViewById(tel_et);//编辑我的电话
        //另一半
        ll_bottom_decorate = (LinearLayout) findViewById(R.id.ll_bottom_decorate);//另一半头像装饰
        img_bootom_head = (RoundedImageView) findViewById(R.id.img_bootom_head);//另一半头像
        img_bootom_head.setImageDrawable(getResources().getDrawable(R.mipmap.headw));
        other_name_tv = (TextView) findViewById(R.id.other_name_tv);   //另一半名字提示
        other_name_et = (EditText) findViewById(R.id.other_name_et);//编辑另一半名字
        tv_we_weddingDate = (TextView) findViewById(R.id.tv_we_weddingDate);//我们的婚期提示
        tv_wedding_day = (TextView) findViewById(R.id.tv_wedding_day);//婚礼日期
        address_tv = (TextView) findViewById(R.id.address_tv);  //婚礼举办地提示
        tv_address = (TextView) findViewById(R.id.tv_wedding_address);//举办地
        domain_name_tv = (TextView) findViewById(R.id.domain_name_tv); //婚礼域名提示.
        domain_name_et = (EditText) findViewById(R.id.domain_name_et);//编辑婚礼域名前缀
        domain_tv = (TextView) findViewById(R.id.domain_tv);//婚礼后缀
        other_tel_tv = (TextView) findViewById(R.id.other_tel_tv);//提示另一半电话
        other_tel_et = (EditText) findViewById(R.id.other_tel_et);//编辑另一半电话

        img_top_head.setOnClickListener(this);// 头像
        findViewById(R.id.rl_my_role).setOnClickListener(this);// 我的角色
        img_bootom_head.setOnClickListener(this);// 对象头像
        findViewById(R.id.rl_wedding_day).setOnClickListener(this);// 婚期
        findViewById(R.id.rlay_information_wedding_address).setOnClickListener(this);// 婚礼举办地

        //头部导航
        TextView tv_tools_dayplan_backcontent = (TextView) findViewById(R.id.tv_tools_dayplan_backcontent);
        TextView tv_tools_dayplan_title = (TextView) findViewById(R.id.tv_tools_dayplan_title);
        TextView tv_tools_dayplan_addtype1 = (TextView) findViewById(R.id.tv_tools_dayplan_addtype1);
        tv_tools_dayplan_backcontent.setText("     ");
        tv_tools_dayplan_title.setText("新人信息");
        tv_tools_dayplan_addtype1.setText("保存");
        tv_tools_dayplan_addtype1.setVisibility(View.VISIBLE);
        tv_tools_dayplan_addtype1.setOnClickListener(this);
        findViewById(R.id.llay_toolsheader_back).setOnClickListener(this);// 返回

    }
    /**
     * 初始化数据
     */
    private void initInfo() {
        uId = DataWareHourse.getInstance().getmUser().getData().get(0).getI_Id();
        isTopBride=true;
    }

    @Override
    protected void onResume() {
        boolean b = getIntent().getBooleanExtra("isForShare",false);
        if(b&&TextUtils.isEmpty(domain_name_et.getText().toString().replaceAll("\\s",""))){
            /**
             * 将焦点移到输入框，弹起输入法
             */
            domain_name_et.requestFocus();
            Utils.showSoftInputWindow(domain_name_et);
        }
        super.onResume();
    }

    /**
     * 获取请柬信息
     */
    private void loadData() {
        String url = Url.GETINVITEMARRYCARDSELECTUID + "&uid=" + uId;
        HttpRequestBean httpRequestBean = new HttpRequestBean(RequestCode.GETREQUEST, url,
                InformationActivity.this, MarryInviteBean.class, "");
        HttpHandleUtil.executeCommonGet(context, httpRequestBean);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        // 设置我的名字输入框可点击宽度为全部
        my_name.setPadding(myname_tv.getWidth() + Utils.dip2px(context, 12.7f), Utils.dip2px(context, 12.7f), Utils.dip2px(context, 2f), Utils.dip2px(context, 12.7f));
        my_tel.setPadding(myname_tv.getWidth() + Utils.dip2px(context, 12.7f), Utils.dip2px(context, 15.3f), Utils.dip2px(context, 2f), Utils.dip2px(context, 18f));

        // 设置另一半姓名输入框可点击宽度为全部
        domain_name_et.setPadding(other_name_tv.getWidth() + Utils.dip2px(context, 12.7f), Utils.dip2px(context, 12.7f), domain_tv.getWidth(), Utils.dip2px(context, 12.7f));
        other_name_et.setPadding(other_name_tv.getWidth() + Utils.dip2px(context, 12.7f), Utils.dip2px(context, 12.7f), Utils.dip2px(context, 2f), Utils.dip2px(context, 12.7f));
        other_tel_et.setPadding(other_name_tv.getWidth() + Utils.dip2px(context, 12.7f), Utils.dip2px(context, 15.3f), Utils.dip2px(context, 2f), Utils.dip2px(context, 18f));
    }


    private void uploadfile(final File saveFile) {
        // 弹框
        Tools.showWaitDialog(this, "上传中...", false);
        if (isTopHead) {//上半部分
            if (!isTopBride) {
                url = RequestCode.SURL + RequestCode.UPLOADINFOPIC + uId + "&key=" + 1;
            } else {
                url = RequestCode.SURL + RequestCode.UPLOADINFOPIC + uId + "&key=" + 2;
            }
        } else {// 另一半
            if (isTopBride) {
                url = RequestCode.SURL + RequestCode.UPLOADINFOPIC + uId + "&key=" + 1;
            } else {
                url = RequestCode.SURL + RequestCode.UPLOADINFOPIC + uId + "&key=" + 2;
            }
        }
        new Thread() {
            @Override
            public void run() {
                Map map = uploadFile(saveFile, url, isTopHead);
                Message msg = handler.obtainMessage(0);
                msg.obj = map;
                handler.sendMessage(msg);
            }
        }.start();
    }

    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case 0:
                    Tools.dismissWaitDialog();
                    Map map = (Map) msg.obj;
                    String result = map.get("result").toString();
                    if (!TextUtils.isEmpty(result)) {
                        Gson gson = new Gson();
                        SimpleBean response = gson.fromJson(result, SimpleBean.class);
                        if (response != null && response.getResCode() != null) {
                            if (response.getResCode().equals("0000")) {
                                CUtils.showToast("上传成功");
                                boolean isTopHead = (boolean) map.get("isTopHead");
                                //设置到当前的控件显示头像
                                if (isTopHead && drawable != null) {
                                    img_top_head.setImageDrawable(drawable);
                                }
                                if (!isTopHead && drawableOther != null) {
                                    img_bootom_head.setImageDrawable(drawableOther);
                                }
                                sendBroadcast(new Intent(ElectronicInvitationActivity.ACTION_REFRESH_INVITATION));
                            } else {
                                CUtils.showToast(response.getMsg());
                            }
                        }
                    } else {
                        CUtils.showToast("上传失败");
                    }
                    break;
            }
        }
    };

    /**
     * android上传文件到服务器
     *
     * @param file       需要上传的文件
     * @param RequestURL 请求的rul
     * @return 返回响应的内容
     */
    public Map uploadFile(File file, String RequestURL, boolean isTopHead) {
        Map map = new HashMap();
        map.put("isTopHead", isTopHead);
        String result = "";
        String BOUNDARY = UUID.randomUUID().toString();
        //边界标识 随机生成
        String PREFIX = "--", LINE_END = "\r\n";
        String CONTENT_TYPE = "multipart/form-data"; //内容类型
        try {
            URL url = new URL(RequestURL);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setReadTimeout(20 * 100000);
            conn.setConnectTimeout(20 * 100000);
            conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setUseCaches(false);
            conn.setRequestMethod("POST"); //请求方式
            conn.setRequestProperty("Charset", "utf-8"); //设置编码
            conn.setRequestProperty("connection", "keep-alive");
            conn.setRequestProperty("Content-Type", CONTENT_TYPE + ";boundary=" + BOUNDARY);
            if (file != null) {
                /** * 当文件不为空，把文件包装并且上传 */
                OutputStream outputSteam = conn.getOutputStream();
                DataOutputStream dos = new DataOutputStream(outputSteam);
                StringBuffer sb = new StringBuffer();
                sb.append(PREFIX);
                sb.append(BOUNDARY);
                sb.append(LINE_END);
                sb.append("Content-Disposition: form-data; name=\"img\"; filename=\"" + file.getName() + "\"" + LINE_END);
                sb.append("Content-Type: application/octet-stream; charset=utf-8" + LINE_END);
                sb.append(LINE_END);
                dos.write(sb.toString().getBytes());
                InputStream is = new FileInputStream(file);
                byte[] bytes = new byte[1024];
                int len = 0;
                while ((len = is.read(bytes)) != -1) {
                    dos.write(bytes, 0, len);
                }
                is.close();
                dos.write(LINE_END.getBytes());
                byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINE_END).getBytes();
                dos.write(end_data);
                dos.flush();
                /**
                 * 获取响应码 200=成功
                 * 当响应成功，获取响应的流
                 */
                int res = conn.getResponseCode();
                if (res == 200) {
                    // 读取返回数据
                    StringBuffer strBuf = new StringBuffer();
                    BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                    String line = null;
                    while ((line = reader.readLine()) != null) {
                        strBuf.append(line).append("\n");
                    }
                    result = strBuf.toString();
                    reader.close();
                    map.put("result", result);
                    return map;
                }
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        map.put("result", result);
        return map;
    }
    private void setViews() {
        if (marryInvite != null) {
            String point = marryInvite.getNvc_Point();
            if (!TextUtils.isEmpty(point) && point.contains(",")) {
                String[] str = point.split(",");
                if (str != null && str.length == 2) {
                    mLongitude = Double.parseDouble(str[0]);
                    mLatitude = Double.parseDouble(str[1]);
                }
            }
            if (!TextUtils.isEmpty(marryInvite.getNvc_MePhoto())) {
                Glide.with(this).load(marryInvite.getNvc_MePhoto()).placeholder(getResources().getDrawable(R.mipmap.headm)).error(R.mipmap.headm).into(img_top_head);
            }
            if (!TextUtils.isEmpty(marryInvite.getMvc_ShePhoto())) {
                Glide.with(this).load(marryInvite.getMvc_ShePhoto()).placeholder(getResources().getDrawable(R.mipmap.headw)).error(R.mipmap.headw).into(img_bootom_head);
            }
            my_name.setText(marryInvite.getNvc_Me());
            my_tel.setText(marryInvite.getNvc_MePhone());

            other_name_et.setText(marryInvite.getNvc_She());
            tv_wedding_day.setText(marryInvite.getNvc_Wedding());
            tv_address.setText(marryInvite.getNvc_Address());
            domain_name_et.setText(marryInvite.getNvc_Domain());
            other_tel_et.setText(marryInvite.getNvc_ShePhone());
            String date = marryInvite.getNvc_Wedding().replaceAll("\\s", "");
            //如果日期中不含有这些将不解析
            if (!TextUtils.isEmpty(date) && date.contains("年") && date.contains("月") && date.contains("日") && date.contains(":")) {
                currentYear = date.substring(0, date.lastIndexOf("年"));
                currentMonth = date.substring(date.lastIndexOf("年") + 1, date.lastIndexOf("月"));
                currentDay = date.substring(date.lastIndexOf("月") + 1, date.lastIndexOf("日"));
                currentHour = date.substring(date.lastIndexOf("日") + 1, date.lastIndexOf(":"));
                currentMinute = date.substring(date.lastIndexOf(":") + 1, date.length());
            }
            boolean isNull=false;
            if (TextUtils.isEmpty(marryInvite.getNvc_MeRole())){
                marryInvite.setNvc_MeRole("新娘");
                isNull=true;
            }
            tv_my_role.setText(marryInvite.getNvc_MeRole());
            if (isNull) {
                saveData2Net();
            }
            if (tv_my_role.getText().toString() != null && tv_my_role.getText().toString().equals("新娘")) {
                isTopBride=true;
            } else {
                isTopBride=false;
            }
            //更新字体颜色
            setBottomColor();
            setTopColor();
        }
    }
    @Override
    public void onSucess(SuccessBean sucessbean) {
        Object data = sucessbean.getData();
        if (data instanceof MarryInviteBean) {
            MarryInviteBean response = (MarryInviteBean) data;
            if (response != null && response.getResCode() != null) {
                if (response.getResCode().equals("0000")) {
                    isGetInformation=true;
                    // 界面关联数据
                    marryInvite = response.getData();
                    setViews();
                } else {
                    CUtils.showToast(response.getMsg());
                }
            }
        } else if (data instanceof SimpleBean) {
            SimpleBean response = (SimpleBean) data;
            if (response.getResCode().equals("0000")) {
                CUtils.showToast("保存成功");
                if (tv_my_role.getText().toString() != null && tv_my_role.getText().toString().equals("新娘")) {
                    isTopBride = true;
                } else {
                    isTopBride = false;
                }
                sendBroadcast(new Intent(ElectronicInvitationActivity.ACTION_REFRESH_INVITATION));
            } else {
                CUtils.showToast(response.getMsg());
            }
        }
    }
    @Override
    public void onError(ErrorBean errorBean) {
        CUtils.showToast("数据请求失败");
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.llay_toolsheader_back:
                finish();
                break;
            case R.id.tv_tools_dayplan_addtype1:
                if (checkData()) { // 校验数据
                    saveData2Net();//我的名字
                }
                break;
            case R.id.img_bootom_head:
                //判断是否当前角色为空,如果是空的代表刚才没有获得到用户信息,不能传否则
                if (!TextUtils.isEmpty(tv_my_role.getText().toString().trim())) {
                isTopHead = false;
                showTouxiang();
                }else {
                    CUtils.showToastInCenter("当前无角色!不可设定");
                }
                break;
            case R.id.img_top_head:
                //判断是否当前角色为空,如果是空的代表刚才没有获得到用户信息,不能传否则
                if (!TextUtils.isEmpty(tv_my_role.getText().toString().trim())) {
                isTopHead = true;
                showTouxiang();
                }else {
                    CUtils.showToastInCenter("当前无角色!不可设定");
                }
                break;
            case R.id.rl_my_role:
                    selectrole();
                break;
            case R.id.dialog_photo_button:
                tv_my_role.setText("新娘");
                //更新页面颜色
                isTopBride = true;
                setTopColor();
                setBottomColor();
                if (dialog != null && dialog.isShowing()) {
                    dialog.dismiss();
                    dialog = null;
                }
                break;
            case R.id.dialog_camera_button:
                tv_my_role.setText("新郎");
                isTopBride = false;
                setTopColor();
                setBottomColor();
                if (dialog != null && dialog.isShowing()) {
                    dialog.dismiss();
                    dialog = null;
                }
                break;
            case R.id.dialog_quxiao_button:
                if (dialog != null && dialog.isShowing()) {
                    dialog.dismiss();
                    dialog = null;
                }
                break;
            case R.id.rl_wedding_day:// 选中我的婚期,打开设置婚期
                if (mDatePopupWindow != null) {
                    mDatePopupWindow.dismiss();
                    mDatePopupWindow = null;
                }
                Utils.hideSoftInputWindow(InformationActivity.this);
                showdatePopupWindow(v);
                break;
            case R.id.tv_cancel_time:  // 取消设置日期
                if (mDatePopupWindow != null) {
                    mDatePopupWindow.dismiss();
                    mDatePopupWindow = null;
                }
                break;
            case R.id.tv_confim_time:  // 确认设置日期
                String weddingDate = currentYear + "年"
                        + currentMonth + "月"
                        + currentDay + "日 "
                        + currentHour + ":"
                        + currentMinute;
                tv_wedding_day.setText(weddingDate);
                if (mDatePopupWindow != null) {
                    mDatePopupWindow.dismiss();
                    mDatePopupWindow = null;
                }
                break;
            case R.id.rlay_information_wedding_address:
                Intent intent = new Intent(this, WeddingAddressActivity.class);
                intent.putExtra("latitude", mLatitude);
                intent.putExtra("longitude", mLongitude);
                intent.putExtra("address", tv_address.getText().toString());
                startActivityForResult(intent, ADDRESS);
                break;
            default:
                break;
        }
    }
    //校验数据
    private boolean checkData() {
        if (TextUtils.isEmpty(my_name.getText().toString().trim())) {
            CUtils.showToast("您还没有填写您的名字哦~");
            return false;
        }
        if (TextUtils.isEmpty(other_name_et.getText().toString().trim())) {
            CUtils.showToast("您还没有填写另一半姓名哦~");
            return false;
        }
      if (TextUtils.isEmpty(domain_name_et.getText().toString().trim())) {
            CUtils.showToast("您还没有填写婚礼域名哦~");
            return false;
        }
        if (!TextUtils.isEmpty(my_tel.getText().toString().trim())) {
            final String REGEX_MOBILE_SIMPLE = "^1[3|5|8|7]\\d{9}$";
            Pattern pattern = Pattern.compile(REGEX_MOBILE_SIMPLE);
            Matcher matcher = pattern.matcher(my_tel.getText().toString());
            if (!matcher.find()) {
                CUtils.showToast("手机号格式错误");
                return false;
            }
        }
        if (!TextUtils.isEmpty(other_tel_et.getText().toString().trim())) {
            final String REGEX_MOBILE_SIMPLE = "^1[3|5|8|7]\\d{9}$";
            Pattern pattern = Pattern.compile(REGEX_MOBILE_SIMPLE);
            Matcher matcher = pattern.matcher(other_tel_et.getText().toString());
            if (!matcher.find()) {
                CUtils.showToast("手机号格式错误");
                return false;
            }
        }
        return true;
    }


    /**
     * 设置新郎与新娘的dialog
     */
    private void selectrole() {
        View view = getLayoutInflater().inflate(R.layout.activity_tools_dialog_photo, null);
        Button cameraBtn = (Button) view.findViewById(R.id.dialog_camera_button);      //新郎
        Button photoBtn = (Button) view.findViewById(R.id.dialog_photo_button);        //新娘
        Button quxiaoBtn = (Button) view.findViewById(R.id.dialog_quxiao_button);      // 取消
        cameraBtn.setText("新郎");
        photoBtn.setText("新娘");
        photoBtn.setOnClickListener(this);
        cameraBtn.setOnClickListener(this);
        cameraBtn.setOnClickListener(this);
        quxiaoBtn.setOnClickListener(this);
        dialog = new Dialog(this, R.style.transparentFrameWindowStyle);
        dialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = dialog.getWindow();
        // 设置显示动画
        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        // 设置显示位置
        dialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        dialog.setCancelable(true);
        dialog.show();
    }
    /**
     * 选择拍照与图库的dialog
     */
    public void showTouxiang() {
        View view = this.getLayoutInflater().inflate(R.layout.activity_tools_dialog_photo, null);
        Button photoBtn = (Button) view.findViewById(R.id.dialog_photo_button);
        Button cameraBtn = (Button) view.findViewById(R.id.dialog_camera_button);
        Button quxiaoBtn = (Button) view.findViewById(R.id.dialog_quxiao_button);
        photoBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    showPhoto();
                dialog.dismiss();
            }
        });
        cameraBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showCamera();
                dialog.dismiss();
            }

        });
        quxiaoBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog = new Dialog(this, R.style.transparentFrameWindowStyle);
        dialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = dialog.getWindow();
        // 设置显示动画
        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = this.getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        // 设置显示位置
        dialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
    }

    /**
     * 调用相机
     */
    public void showCamera() {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]
                    {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_SDCARD);
        } else {
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File file;
            if (isTopHead) {
                file = new File(Environment.getExternalStorageDirectory(), "touxiang.jpg");
            } else {
                file = new File(Environment.getExternalStorageDirectory(), "touxiang2.jpg");
            }

            //下面这句指定调用相机拍照后的照片存储的路径
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
            this.startActivityForResult(intent, 2);
        }
    }

    /**
     * 调用相册
     */
    private void showPhoto() {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED
                || ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            //申请MOUNT_UNMOUNT_FILESYSTEMS权限
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_CAMERA);
        } else {
            Intent intent = new Intent(Intent.ACTION_PICK, null);
            //下面这句指定调用相机拍照后的照片存储的路径
            intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
            this.startActivityForResult(intent, 1);
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode != 0) {
            switch (requestCode) {
                // 如果是直接从相册获取
                case 1:
                    if (data != null) {
                        //裁剪图片
                        startPhotoZoom(data.getData());
                    }
                    break;
                // 如果是调用相机拍照时
                case 2:
                    File temp;
                    if (isTopHead) {
                        temp = new File(Environment.getExternalStorageDirectory(), "touxiang.jpg");
                    } else {
                        temp = new File(Environment.getExternalStorageDirectory(), "touxiang2.jpg");
                    }
                    //裁剪图片
                    if (temp != null)
                        startPhotoZoom(Uri.fromFile(temp));
                    break;
                // 取得裁剪后的图片
                case 3:
                    /**
                     * 非空判断大家一定要验证，如果不验证的话，在剪裁之后如果发现不满意，要重新裁剪，丢弃
                     */
                    if (data != null) {
                        //保存图片到ImageView
                        setPicToView(data);
                    }
                    break;
                case ADDRESS:
                    mLongitude = data.getDoubleExtra("longitude", 0);
                    mLatitude = data.getDoubleExtra("latitude", 0);
                    String address = data.getStringExtra("address");
                    tv_address.setText(address);
                    break;
            }
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    /**
     * 裁剪图片方法实现
     */
    public void startPhotoZoom(Uri uri) {
        Intent intent = new Intent("com.android.camera.action.CROP");
        intent.setDataAndType(uri, "image/*");
        //下面这个crop=true是设置在开启的Intent中设置显示的VIEW可裁剪
        intent.putExtra("crop", "true");
        // aspectX aspectY 是宽高的比例
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 1);
        // outputX outputY 是裁剪图片宽高
        intent.putExtra("outputX", 150);
        intent.putExtra("outputY", 150);
        intent.putExtra("return-data", true);
        this.startActivityForResult(intent, 3);
    }

    /**
     * 保存裁剪之后的图片数据
     */
    private void setPicToView(Intent picdata) {
        Bundle extras = picdata.getExtras();
        if (extras != null) {
            Bitmap photo = extras.getParcelable("data");
            //保存图片
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            photo.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byte[] byteArray = stream.toByteArray();
            File saveFile;
            if (isTopHead) {
                drawable = new BitmapDrawable(photo);
                saveFile = new File(FileUtil.getImgFile(this), "myhaed.jpg");
                myHaed = saveFile.getPath();//上传我的头像
                if (!TextUtils.isEmpty(myHaed)) {
                    uploadfile(new File(myHaed));
                }
            } else {
                drawableOther = new BitmapDrawable(photo);
                saveFile = new File(FileUtil.getImgFile(this), "otherhaed.jpg");
                otherHaed = saveFile.getPath();
                //上传他的
                if (!TextUtils.isEmpty(otherHaed)) {
                    uploadfile(new File(otherHaed));
                }
            }
            try {
                FileOutputStream fileOutputStream = new FileOutputStream(saveFile);
                fileOutputStream.write(byteArray, 0, byteArray.length);
                fileOutputStream.flush();
                fileOutputStream.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 设置婚期的popupWindow
     */
    private void showdatePopupWindow(View view) {
        // 一个自定义的布局，作为显示的内容
        View contentView = LayoutInflater.from(this).inflate(R.layout.pop_select_wedding_time, null);
        TextView mCancelTv = (TextView) contentView.findViewById(R.id.tv_cancel_time);
        TextView mConfimTv = (TextView) contentView.findViewById(R.id.tv_confim_time);
        mViewYear = (WheelView) contentView.findViewById(R.id.wheelview_year);
        mViewMonth = (WheelView) contentView.findViewById(R.id.wheelview_month);
        mViewDay = (WheelView) contentView.findViewById(R.id.wheelview_day);
        mViewHour = (WheelView) contentView.findViewById(R.id.wheelview_hour);
        mViewMinute = (WheelView) contentView.findViewById(R.id.wheelview_minute);
        //两按钮的点击事件
        mCancelTv.setOnClickListener(this);
        mConfimTv.setOnClickListener(this);
        initTimes();//初始化显示是数据
        //设置数据
        mViewYear.setData(mYears);//设置年数据
        mViewMonth.setData(mMonths);//设置月数据
        updateDays();//设置日期数据
        mViewHour.setData(mHours);
        mViewMinute.setData(mMinutes);
        String date = tv_wedding_day.getText().toString().replaceAll("\\s", "");
        LogUtil.i("4646", "目前显示设置时间" + date);
        //如果日期中不含有这些将不解析
        if (!TextUtils.isEmpty(date) && date.contains("年") && date.contains("月") && date.contains("日") && date.contains(":")) {
            currentYear = date.substring(0, date.lastIndexOf("年"));
            currentMonth = date.substring(date.lastIndexOf("年") + 1, date.lastIndexOf("月"));
            currentDay = date.substring(date.lastIndexOf("月") + 1, date.lastIndexOf("日"));
            currentHour = date.substring(date.lastIndexOf("日") + 1, date.lastIndexOf(":"));
            currentMinute = date.substring(date.lastIndexOf(":") + 1, date.length());
        }
        if (currentYear.equals("2016") && currentMonth.equals("01") && currentDay.equals("01") && currentHour.equals("00") && currentMinute.equals("00")) {
            getTime();
        }
        setDefaultSelect(mYears, mViewYear, currentYear);
        setDefaultSelect(mMonths, mViewMonth, currentMonth);
        setDefaultSelect(mDays, mViewDay, currentDay);
        setDefaultSelect(mHours, mViewHour, currentHour);
        setDefaultSelect(mMinutes, mViewMinute, currentMinute);

        //设置滑动监听
        mViewYear.setOnSelectListener(R.id.wheelview_year, this);
        mViewMonth.setOnSelectListener(R.id.wheelview_month, this);
        mViewDay.setOnSelectListener(R.id.wheelview_day, this);
        mViewHour.setOnSelectListener(R.id.wheelview_hour, this);
        mViewMinute.setOnSelectListener(R.id.wheelview_minute, this);
        mDatePopupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
        mDatePopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        //点击空白处时，隐藏掉pop窗口
        mDatePopupWindow.setTouchable(true);
        mDatePopupWindow.showAtLocation(view, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
        //在PopupWindow里面就加上下面代码，让键盘弹出时，不会挡住pop窗口。
        mDatePopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }

    /**
     * 设置默认数据,需要给数组,以及控件,还有比对的值
     *
     * @param data
     * @param wv
     * @param value
     */
    private void setDefaultSelect(ArrayList<String> data, WheelView wv, String value) {
        //设置当前选择
        for (int i = 0; i < data.size(); i++) {
            String s = data.get(i);
            if (s.equals(value)) {
                wv.setDefault(i);
                break;
            }
            if (!s.equals(value) && i == data.size() - 1) {//如果到了最后一个还没,设置第一个做数据
                wv.setDefault(0);
            }
        }
    }

    private void initTimes() {
        //年份
        //适配器支持从string,所以加个""变成String
        mYears = new ArrayList();
        for (int i = 0; i < 12; i++) {
            mYears.add(2016 + i + "");
        }
        //月份
        //适配器支持从string,所以加个""变成String
        mMonths = new ArrayList<String>();
        for (int i = 1; i <= 12; i++) {
            if (i < 10) {
                mMonths.add("0" + i);
                continue;
            }
            mMonths.add(i + "");
        }
        //小时数据
        //适配器支持从string,所以加个""变成String
        mHours = new ArrayList<String>();
        for (int i = 0; i < 24; i++) {
            if (i < 10) {
                mHours.add("0" + i);
                continue;
            }
            mHours.add(i + "");
        }
        //分钟
        //适配器支持从string,所以加个""变成String
        mMinutes = new ArrayList<String>();
        for (int i = 0; i < 60; i++) {
            if (i < 10) {
                mMinutes.add("0" + i);
                continue;
            }
            mMinutes.add(i + "");
        }
    }
    /**
     * 设置每天的方法( 年月都需要设置更新)
     * synchronized防止年与月同时操作导致崩溃
     */
    ArrayList<String> mDays = new ArrayList<String>();
    private synchronized void updateDays() {
        int year = Integer.parseInt(currentYear);
        int month = Integer.parseInt(currentMonth);
        LogUtil.i("4646", "当前年份:" + year + "年" + month);
        if (mDays == null) {
            mDays = new ArrayList();
        }
        if (month == 2) {//如果是二月(这里比较特殊有可能28或者29)
            if (isLeapYear(year)) {//闰年
                addDay2List(29);
            } else {
                addDay2List(28);
            }
            //1,3,5,7,8,10,12这些月份是31天
        } else if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
            addDay2List(31);
        } else {//其他全是30天
            addDay2List(30);
        }
        mViewDay.refreshData(mDays);
        for (int i = 0; i < mDays.size(); i++) {
            if (mDays.get(i).equals(currentDay)) {
                mViewDay.setDefault(i);
                break;
            }
            if (i == mDays.size() - 1) {//如果是最后一个还不等于当前月份,就设置这个月的最后一天,有可能上月的天数多于本月
                if (!mDays.get(i).equals(currentDay)) {
                    mViewDay.setDefault(i);
                }
            }
        }
    }

    /**
     * 给总共的天数,添加到集合
     * @param dayCount
     */
    private void addDay2List(int dayCount) {
        mDays.clear();
        for (int i = 1; i <= dayCount; i++) {
            if (i < 10) {
                mDays.add("0" + i);
            } else {
                mDays.add(i + "");
            }
        }
    }
    /**
     * 判断是否是闰年
     */
    public static boolean isLeapYear(int Year) {
        boolean flag = false;
        if ((Year % 4 == 0) && ((Year % 100 != 0) || (Year % 400 == 0))) {
            flag = true;
        }
        return flag;
    }
    /**
     * 保存数据到网络
     * 1:我的名字 2:我的角色 3:另一半名字 4:我们的结婚日期
     * 5:婚礼举办地 6:坐标 7:域名 8:绑定手机号9:我的手机号10:是否显示联系方式("true","false")
     */
    public void saveData2Net() {
        String date = tv_wedding_day.getText().toString();
        date = date.replace(" ", "aa");
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("meName", my_name.getText().toString().trim());
        map.put("meRole", tv_my_role.getText().toString());
        map.put("sheName", other_name_et.getText().toString().trim());
        map.put("wedding", date);
        map.put("address", tv_address.getText().toString());
        map.put("point", mLongitude + "," + mLatitude);
        map.put("domain", domain_name_et.getText().toString().trim());
        map.put("phone", other_tel_et.getText().toString().trim());
        map.put("phoneShow", true);
        map.put("mePhone", my_tel.getText().toString().trim());
        String parameters = Utils.getUrlParameters(map);

        String url = RequestCode.SURL + RequestCode.SAVEMARRY + uId + parameters;
        HttpRequestBean httpRequestBean = new HttpRequestBean(RequestCode.POSTEQUEST, url, this, SimpleBean.class, "");
        HttpHandleUtil.executeCommonPost(this, httpRequestBean);
    }


    /**
     * 获取系统时间
     */
    public void getTime() {
        Calendar c = Calendar.getInstance();
        currentYear = c.get(Calendar.YEAR) + "";
        int mon = c.get(Calendar.MONTH);
        if (mon < 10) {
            currentMonth = "0" + (mon + 1);
        } else {
            currentMonth = (mon + 1) + "";
        }
        int day = c.get(Calendar.DAY_OF_MONTH);
        if (day < 10) {
            currentDay = "0" + day;
        } else {
            currentDay = day + "";
        }
        //取得系统时间：
        int hour = c.get(Calendar.HOUR_OF_DAY);
        if (hour < 10) {
            currentHour = "0" + hour;
        } else {
            currentHour = hour + "";
        }
        int min = c.get(Calendar.MINUTE);
        if (min < 10) {
            currentMinute = "0" + min;
        } else {
            currentMinute = min + "";
        }
        LogUtil.i("4646", "当前系统时间: " + currentYear);
        LogUtil.i("4646", "当前系统时间: " + currentMonth);
        LogUtil.i("4646", "当前系统时间: " + currentDay);
        LogUtil.i("4646", "当前系统时间: " + currentHour);
        LogUtil.i("4646", "当前系统时间: " + currentMinute);
    }

    /**
     * 这个是wheelview的滑动完成的监听,
     *
     * @param ViewId
     * @param id
     * @param text
     */
    @Override
    public void endSelect(int ViewId, int id, String text) {
        currentDay = mViewDay.getItemText(mViewDay.getSelected());
        if (ViewId == R.id.wheelview_year) {
            currentYear = mViewYear.getItemText(mViewYear.getSelected());
            updateDays();//更新每月的天数
        } else if (ViewId == R.id.wheelview_month) {
            currentMonth = mViewMonth.getItemText(mViewMonth.getSelected());
            updateDays();//更新每月的天数
        } else if (ViewId == R.id.wheelview_day) {
            currentDay = mViewDay.getItemText(mViewDay.getSelected());
        } else if (ViewId == R.id.wheelview_hour) {
            currentHour = mViewHour.getItemText(mViewHour.getSelected());
        } else if (ViewId == R.id.wheelview_minute) {
            currentMinute = mViewMinute.getItemText(mViewMinute.getSelected());
        }
    }

    /**
     * 这个是wheelview的滑动中的监听,
     *
     * @param ViewId
     * @param id
     * @param text
     */
    @Override
    public void selecting(int ViewId, int id, String text) {
        currentDay = mViewDay.getItemText(mViewDay.getSelected());
        if (ViewId == R.id.wheelview_year) {
            currentYear = mViewYear.getItemText(mViewYear.getSelected());
            updateDays();//更新每月的天数
        } else if (ViewId == R.id.wheelview_month) {
            currentMonth = mViewMonth.getItemText(mViewMonth.getSelected());
            updateDays();//更新每月的天数
        } else if (ViewId == R.id.wheelview_day) {
            currentDay = mViewDay.getItemText(mViewDay.getSelected());
        } else if (ViewId == R.id.wheelview_hour) {
            currentHour = mViewHour.getItemText(mViewHour.getSelected());
        } else if (ViewId == R.id.wheelview_minute) {
            currentMinute = mViewMinute.getItemText(mViewMinute.getSelected());
        }
    }
}
